package com.xc.sbdemo.handler;

import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;

/**
 * 全局异常处理
 */
@ControllerAdvice
public class GlobalExceptionHandler {

    @ExceptionHandler(RuntimeException.class)
    public String handle(Exception e, Model model) {
        model.addAttribute("level","全局异常");
        model.addAttribute("errorInfo",e.getMessage());
        return "error";
    }

}
